#include "client.h"
#include "sock.h"
#include "messageComm.h"

Client::Client()
{
  sock_fd_ = 0;
}

Client::~Client()
{
  close(sock_fd_);
}

void Client::init(const char* ip, size_t port)
{
  sock_fd_ = SockOpt::Socket(); 
  if(sock_fd_ < 0)
  {
    std::cout << "socket fail" << std::endl;
    return;
  }

  if(0 > SockOpt::Connect(sock_fd_, ip, port))
  {
    std::cout << "connect err :" << ip << ":" << port << std::endl;
    return;
  }
}

void Client::start()
{
  Cmd::RegisterUserCmd send;
  strcpy(send.acccount_, "213");
  strcpy(send.username_, "123");
  strcpy(send.passwd_, "312");

  if(0 > SockOpt::SendCmd(&send, sizeof(send), sock_fd_))
  {
    Logger::error("send fail");
  }

  while(1)
  {}
}

